-
Notifications
You must be signed in to change notification settings - Fork 224
Fix GetRelativePath with different volumes #2685
Conversation
@@ -86,6 +86,12 @@ public static string GetRelativePath(string path1, string path2, char separator) | |||
if (Microsoft.Dnx.Runtime.RuntimeEnvironmentHelper.IsWindows) | |||
{ | |||
compare = StringComparison.OrdinalIgnoreCase; | |||
// check if paths are on the same volume | |||
if (string.Equals(path1.Substring(1, 1), ":") && !string.Equals(path1.Substring(0, 2), path2.Substring(0, 2), compare)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possible index out of range exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that the best way to get the drive letter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path.GetPathRoot
5a9247f
to
a18092d
Compare
Updated |
new object[] { "../folder1/file", "C:\\folder\\file", "C:\\folder1\\file" }, | ||
new object[] { "H:\\folder\\file", "C:\\folder\\file", "H:\\folder\\file" }, | ||
new object[] { "folder/file", "C:\\", "C:\\folder\\file" }, | ||
new object[] { "..\\", "C:\\folder\\file", "C:\\" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the result here correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
a18092d
to
7ea0bf0
Compare
Once travis passes |
7ea0bf0
to
f651a80
Compare
f651a80
to
8ec9f73
Compare
#2596
@victorhurdugaci @davidfowl